﻿using System;

namespace Entities
{
    [Serializable]
    public class tblCategory
    {
        private string category_name;
        private string category_des;
        private string image;
        private int parent_id;
        private DateTime date_added;
        private DateTime date_modified;

        public tblCategory() {}

        public tblCategory(string category_name, string category_des, string image, int parent_id, DateTime date_added, DateTime date_modified)
        {
            this.category_name = category_name;
            this.category_des = category_des;
            this.image = image;
            this.parent_id = parent_id;
            this.date_added = date_added;
            this.date_modified = date_modified;
        }

        public string categoryName
        {
            get { return this.category_name; }
            set
            {
                if (value == null)
                    throw new Exception("Tên nhóm sản phẩm không được để trống!");
                this.category_name = value;
            }
        }

        public string categoryDes
        {
            get { return this.category_des; }
            set
            {
                this.category_des = value;
            }
        }

        public string Image
        {
            get { return this.image; }
            set
            {
                this.image = value;
            }
        }

        public int parentID
        {
            get { return this.parent_id; }
            set
            {
                this.parent_id = value;
            }
        }

        public DateTime dateAdded
        {
            get { return this.date_added; }
            set
            {
                this.date_added = value;
            }
        }

        public DateTime dateModified
        {
            get { return this.date_modified; }
            set
            {
                this.date_modified = value;
            }
        }

        public override string ToString()
        {
	        return this.category_name+"; "+this.category_des+"; "+this.image+"; "+this.parent_id+"; "+this.date_added+"; "+this.date_modified+"; ";
	    }
	    public override bool Equals(Object obj)
	    {
            tblCategory me = (tblCategory)obj;
	        bool ret=this.categoryName.Equals(me.categoryName);
	        return ret;
	    }
	    public override int GetHashCode()
	    {
	        return this.categoryName.GetHashCode();
	    }

    }
}
